import {debounce} from "./utils";
import BackTop from "@/components/content/backTop/BackTop";
import {POP, NEW, SELL} from "./const";



export const itemListenerMinin = {
  data(){
    return{
      itemImgListener: null,
      refresh: null
    }
  },
  mounted(){
     this.refresh = debounce(this.$refs.scroll.refresh,100)
    // //监听图片有没有加载完成
    this.itemImgListener = ()=> {
      this.refresh()
    }
    this.$bus.$on('itemimgload',this.itemImgListener)
  }
}
export const backTopMixin = {
  components: {
    BackTop
  },
  data() {
    return {
      isshow: false
    }
  },
  methods: {
    backClick() {
        this.$refs.scroll.scrollTo(0,0)
    },


  }
}
export const tabControlMixin = {
  data() {
    return {
      currentType: POP
    }
  },
  methods: {
    tabClick(index) {
      switch (index) {
        case 0:
          this.currentType = POP
          break
        case 1:
          this.currentType = NEW
          break
        case 2:
          this.currentType = SELL
          break
      }
      console.log(this.currentType);
    }
  }
}
